﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using WF = CPPEI.WorkflowCore;

namespace Demo.UserControls
{
    public partial class WorkflowStateViewer : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Guid instanceId = new Guid(Request.QueryString["wf:instance"]);
            WF.Instance instance = WF.Engine.Get(instanceId);
            if (instance != null)
            {
                if(instance.IsFinished)
                {
                    _ctlWFState.InnerText = string.Format("流程现在处于：{0}({1}),已经完成",
                        instance.State.Activity.Name,
                        instance.State.Activity.Code);
                }
                else
                {
                    _ctlWFState.InnerText = string.Format("流程现在处于：{0}({1}),该{2}处理",
                        instance.State.Activity.Name,
                        instance.State.Activity.Code,
                        instance.State.Actors.ToString());
                }
            }
        }
    }
}